package dbhelper

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var Db *gorm.DB

func InitDB() *gorm.DB {
	db, err := gorm.Open("mysql", "root:123456@(127.0.0.1:3306)/proj?charset=utf8&parseTime=True&loc=Local")
	if err != nil {
		panic(err)
	}

	db.LogMode(true)
	db.SingularTable(true)
	db.DB().SetConnMaxIdleTime(50)
	db.DB().SetMaxOpenConns(100)

	return db
}
